package zhongbo.javaweb.instagram.service.model;

import lombok.Getter;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import zhongbo.javaweb.instagram.dao.IBaseDao;
import zhongbo.javaweb.instagram.model.BaseModel;

import java.util.List;

/**
 * 说明：
 *
 * @author zhongboWork
 * @version 1.0
 * @since 2021-12-21 16:21
 */
@Slf4j
@Getter
public abstract class BaseService<MODEL extends BaseModel> {

    @Autowired
    private IBaseDao<MODEL> baseDao;

    public MODEL findOne(String id) {
        return baseDao.getById(id);
    }

    public MODEL delete(String id) {
        return baseDao.removeById(id);
    }

    public MODEL addOrUpdate(MODEL model) {
        return baseDao.update(model);
    }

    public List<MODEL> findAll() {
        return baseDao.getList();
    }
}
